#ifndef _MYDATA_H
#define _MYDATA_H

#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>

enum MYDATA_RET {
    MYDATA_OK = 0,
    MYDATA_FAIL,
    MYDATA_AUTH_ERR,
    MYDATA_NOT_LOGIN,
};

/* mydata operations set. */
struct mydata_ops{
    char *name;
    char *desc;

    int (*init)(void *real_name);
    int (*end)(void);
    
    /** Session **/
    // insert, update, remove
    int (*insert_session)(Session *session);
    int (*remove_session)(const char *uuid);
    // verify
    int (*session_exist)(const char *uuid, uint32_t *user_id);
    int (*session_user_exist)(uint32_t user_id, char **uuid);
    // other

    /** User **/
    // insert, update, remove
    int (*insert_user)(User *user);
    int (*update_user)(User *user, uint32_t field);
    int (*remove_user)(uint32_t user_id);
    // verify
    int (*user_mail_exist)(const char *mail, uint32_t *user_id);
    int (*mail_passwd_match)(const char *mail, const char *passwd, uint32_t *user_id);
    int (*id_passwd_match)(uint32_t user_id, const char *passwd);
    // get
    int (*get_user_by_id)(uint32_t user_id, User **user);
    int (*get_user_by_mail)(const char *mail, User **user);
    int (*get_user_list)(ArrayTable *result);

    /** Note **/
    // insert, update, remove
    int (*insert_note)(Note *note);
    int (*update_note)(Note *note, uint32_t field);
    int (*remove_note)(uint64_t note_id);
    // verify
    int (*own_note)(uint32_t user_id, uint64_t note_id);
    int (*note_is_public)(uint64_t note_id);
    int (*note_is_shared)(uint64_t note_id, uint32_t user_id);
    // get
    int (*get_note_by_id)(uint64_t note_id, Note **note);
    int (*get_note_by_uuid)(const char *uuid, Note **note);
    int (*get_all_public_note_number)(uint64_t *number);
    int (*get_all_public_note_list)(uint64_t start, uint32_t count, ArrayTable *result);
    int (*get_my_note_number)(uint32_t user_id, uint64_t *number);
    int (*get_my_note_list)(uint32_t user_id, uint64_t start, uint32_t count, ArrayTable *result);

    /** Tag **/
    // insert, update, remove
    int (*insert_tag)(Tag *tag);
    int (*remove_tag)(uint64_t note_id, const char *tag);
    int (*remove_tags)(uint64_t note_id);
    // verify
    int (*tag_exist)(uint64_t note_id, const char *tag);
    // get
    int (*get_tags)(uint64_t note_id, ArrayTable *result);
    int (*get_tag_list)(uint32_t user_id, ArrayTable *result);
    /*

    int (*get_note_by_id)(uint32_t my_id, uint64_t note_id, uint32_t field, Note **note);

    int (*get_my_note_number)(uint32_t my_id, uint32_t *number);
    int (*get_my_note_list)(uint32_t my_id, uint32_t start, uint32_t count, uint32_t field, NoteArray *result);

    int (*get_user_shared_note_number)(uint32_t my_id, uint32_t user_id, uint32_t *number);
    int (*get_user_shared_note_list)(uint32_t my_id, uint32_t user_id, uint32_t start, uint32_t count, uint32_t field, NoteArray *result);

    int (*get_all_shared_note_number)(uint32_t my_id, uint64_t *number);
    int (*get_all_shared_note_list)(uint32_t my_id, uint64_t start, uint32_t count, uint32_t field, NoteArray *result);

    int (*get_user_public_note_number)(uint32_t user_id, uint32_t *number);
    int (*get_user_public_note_list)(uint32_t user_id, uint32_t start, uint32_t count, uint32_t field, NoteArray *result);




    int (*get_note_by_uuid)(uint32_t my_id, char *uuid, uint32_t field, Note **note);
    */
};

#ifdef __cplusplus
}
#endif
#endif /* _MYDATA_H */
